package cn.shop.gameapi.util;


/**
 * @author : 李一涵
 * @date : Created in 2021-12-8 10:26
 * @description :
 */
public class ResponseInfo<T> {

    private String msg;
    private Integer code;
    private Object data;

    public static <T> ResponseInfo<T> ok(T t) {
        ResponseInfo<T> responseInfo = new ResponseInfo<>();
        responseInfo.setCode(1);
        responseInfo.setData(t);
        responseInfo.setMsg("");
        return responseInfo;
    }

    public static <T> ResponseInfo<T> ok() {
        ResponseInfo<T> responseInfo = new ResponseInfo<>();
        responseInfo.setCode(1);
        responseInfo.setMsg("");
        return responseInfo;
    }

    public static <T> ResponseInfo<T> failed(T t) {
        ResponseInfo<T> responseInfo = new ResponseInfo<>();
        responseInfo.setCode(2);
        responseInfo.setMsg("");
        responseInfo.setData(t);
        return responseInfo;
    }

    public static <T> ResponseInfo<T> failed(String msg) {
        ResponseInfo<T> responseInfo = new ResponseInfo<>();
        responseInfo.setCode(2);
        responseInfo.setMsg(msg);
        return responseInfo;
    }

    public static <T> ResponseInfo<T> failed(String msg, T t) {
        ResponseInfo<T> responseInfo = new ResponseInfo<>();
        responseInfo.setCode(2);
        responseInfo.setData(t);
        responseInfo.setMsg(msg);
        return responseInfo;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
